<?php 
/*********************************************************
This file provides means to unput mo information by
preparing customer
*********************************************************/

/*********************************************************
includes	
*********************************************************/
require_once 'config.inc';
require_once '_common.inc';
require_once '_customer.inc';
require_once '_db.inc';
require_once '_rsa.inc';
require_once '_ui.inc';

/*********************************************************
set the correct time zone to eliminate warnings in debug
*********************************************************/
/*
date_default_timezone_set('America/New_York');

$script_tz = date_default_timezone_get();

if (strcmp($script_tz, ini_get('date.timezone'))){
    echo 'Script timezone differs from ini-set timezone.';
}
*/
/*********************************************************
connect to db
*********************************************************/
$customer_conn = db_connect(CUSTOMER_DB_USER, CUSTOMER_DB_PASSWORD);

/*********************************************************
get available cash from customer account
*********************************************************/
$alice_funds = null;
$sql = "select balance from c_account where name = 'Customer-Alice'";

$alice_funds = db_do_query($customer_conn, $sql);

foreach($alice_funds as $af) {
   	$alice_balance = $af['BALANCE'];
}

$alice_string = "Customer has " . $alice_balance . " total funds available.";

/*********************************************************
close db connection
*********************************************************/
oci_close($customer_conn);


/*********************************************************
declare default variables for form
*********************************************************/
$idstring = 'Alice:Smith:123456789';
$amount = 1000;
$number = 10;
$cheat = 0;
//possible future use
//$user = '';
//$password = '';

?>
<HTML>

<HEAD>
	<title>Enter Money Order Characteristics</title>
</HEAD>

<?php
ui_print_header('Customer - Enter Money Order Characteristics');
?>

<h2><?php echo $alice_string;?></h2>

<FORM action="1R_2_CustomerCommitMO.php" method="post">
	<TABLE border="0">
		<TR>
			<TD>ID String</TD>
			<TD>
			<input type="text" size="144" name="idstring" value="<?php echo $idstring;?>">
			</TD>
		</TR>

		<TR>
			<TD>Amount</TD>
			<TD>
			<input type="text" size="24" name="amount" value="<?php echo $amount;?>" >
			</TD>
		</TR>

		<TR>
			<TD>Number</TD>
			<TD>
			<input type="text" size="24" name="number" value="<?php echo $number;?>">
			</TD>
		</TR>

	<TR>
		<TD>Cheat?</TD>
			<TD>
			<input type="checkbox" name="cheat" value="1"> Yes!
			</TD>
	</TR>

	<TR>
		<TD colspan="2" align="center">
			<input type="submit" value="Create Money Orders">
		</TD>
		</TR>
	</TABLE>
</FORM>

<?php
ui_print_footer(date('Y-m-d H:i:s'));
?>
